//用户点击登陆按钮的动作
$(function() {
/*
	$('#startjpush').click(function(){
		console.log('我进入了设置alias的点击事件');
		window.plugins.jPushPlugin.setTagsWithAlias([], '12345678');
	});
*/
	$("#dologin").click(function() {

		
		//全新修改了登陆的套路
		var tel = $("#tel").val();
		var password = $("#password").val();
		var data = {
			'tel' : tel,
			'password' : password,
		};
		var param = transformDateToStr(data);
		console.log(param);
		
		
		$("#loadingmodel").modal({
			backdrop : 'static',
			keyboard : 'false',
			show : "true"
		});
		
		$.ajax({
			type : "POST",
			url : baseUrl + loginUrl,
			timeout : 20000, //超时时间设置，单位毫秒
			data : param,
			contentType : "application/x-www-form-urlencoded",
			dataType : "json",
			success : function(args) {
				//console.log('<<============1============>>');
				$('#loadingmodel').modal('hide');
				var sResultData = args.resultData;
				var sResultMsg = args.resultMsg;
				var sResultCode = args.resultCode;
				if (sResultCode == 10) {//登陆成功
					//console.log('<<============2============>>');
					//alert(tel);
					
					var jResultData = eval(sResultData);
					console.log(jResultData);
					
					var ui = {
						userID : jResultData.id,
						realName : jResultData.realname,
						tel : tel
					}
			
					saveInfo("ui", ui);
					
					//进行jpush的初始化
					app.initialize();
					window.plugins.jPushPlugin.setTagsWithAlias([],ui.tel);
					
					summer.openWin({
						"id" : 'index',
						"url" : 'index.html',
						"isKeep" : false	
					});
					
				} else if (sResultCode == 30) {
					//console.log('<<============3============>>');
					$('#loadingmodel').modal('hide');
					UM.alert({
						title : '提示内容',
						text : sResultMsg,
						btnText : ["", "确定"],
					});
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				//console.log('<<============4============>>');
				if (textStatus == 'timeout') {
					$('#loadingmodel').modal('hide');
					$('#loadingmodel').on('hidden.bs.modal', function() {
						summer.toast({
							"msg" : "网络连接不可用，请稍后重试"
						});
					});
				}
			}
		});
	})
})
